import http from '@/utils/http'

const BASE_URL = '/test/ticketOrders'

export interface TicketOrdersResp {
  id: string
  orderNumber: string
  passengerName: string
  flightNumber: string
  departureCity: string
  arrivalCity: string
  departureTime: string
  arrivalTime: string
  ticketPrice: string
  orderStatus: string
  createdAt: string
  updatedAt: string
  createUserString: string
  updateUserString: string
  disabled: boolean
}
export interface TicketOrdersDetailResp {
  id: string
  orderNumber: string
  passengerName: string
  flightNumber: string
  departureCity: string
  arrivalCity: string
  departureTime: string
  arrivalTime: string
  ticketPrice: string
  orderStatus: string
  createdAt: string
  updatedAt: string
  createUserString: string
  updateUserString: string
}
export interface TicketOrdersQuery {
  orderNumber: string | undefined
  passengerName: string | undefined
  flightNumber: string | undefined
  departureCity: string | undefined
  arrivalCity: string | undefined
  departureTime: string | undefined
  arrivalTime: string | undefined
  ticketPrice: string | undefined
  orderStatus: string | undefined
  createdAt: string | undefined
  sort: Array<string>
}
export interface TicketOrdersPageQuery extends TicketOrdersQuery, PageQuery {}

/** @desc 查询航空机票订单列表 */
export function listTicketOrders(query: TicketOrdersPageQuery) {
  return http.get<PageRes<TicketOrdersResp[]>>(BASE_URL, query)
}

/** @desc 查询航空机票订单详情 */
export function getTicketOrders(id: string) {
  return http.get<TicketOrdersDetailResp>(`${BASE_URL}/${id}`)
}

/** @desc 新增航空机票订单 */
export function addTicketOrders(data: any) {
  return http.post(BASE_URL, data)
}

/** @desc 修改航空机票订单 */
export function updateTicketOrders(data: any, id: string) {
  return http.put(`${BASE_URL}/${id}`, data)
}

/** @desc 删除航空机票订单 */
export function deleteTicketOrders(id: string) {
  return http.del(BASE_URL, { ids: [id] })
}

/** @desc 导出航空机票订单 */
export function exportTicketOrders(query: TicketOrdersQuery) {
  return http.download(`${BASE_URL}/export`, query)
}
